package edu.njust.LabSystem.Service;

import edu.njust.LabSystem.dao.IStudent;
import edu.njust.LabSystem.entity.MybatisUtil;
import edu.njust.LabSystem.entity.Student;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class IStudentService {

	public List<Student> getByStudentsNumber(String id){
		SqlSession sqlSession=MybatisUtil.getSqlSession();
		IStudent mapper=sqlSession.getMapper(IStudent.class);
		List<Student> students=mapper.getStudentsById(id);
		
		sqlSession.close();	
		
		return students;
	}
	public Student getStudentById(String id){

		SqlSession sqlSession=MybatisUtil.getSqlSession();
		IStudent mapper=sqlSession.getMapper(IStudent.class);
		Student student=mapper.getStudentById(id);
		
		sqlSession.close();	
		
		return student;
	}
	public void updateStudent(Student student){
		SqlSession sqlSession=MybatisUtil.getSqlSession();
		IStudent mapper=sqlSession.getMapper(IStudent.class);
		mapper.updateStudent(student);
		sqlSession.commit();
		sqlSession.close();
	}
}
